home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Hacks / Hacks ’87 / HD Runner ƒ / Launch HD Runner.c < prev    next >
Text File  |  1987-04-14  |  1KB  |  51 lines

  1. /*
  2.   * A stub application that can live on the desktop and invoke "HD Runner" in the system folder.
  3.   * Done this way instead of Oasis's document dodge so that it can be found in Transfer menus.
  4.   * It only beeps on errors because we don't want to initialize the mess of managers necessary
  5.   * to complain properly. Besides, this should be small.
  6.   */
  7.  
  8. #include    <FileMgr.h>
  9. #include    <HFS.h>
  10.  
  11. #define    NULL            0L
  12. #define    R_RUNNER        128            /* ID of "HD Runner" string */
  13.  
  14. main()
  15. {
  16.     HParamBlockRec        myHPB;
  17.     WDPBRec                myWDPB;
  18.     register StringHandle    HDRunner;
  19.  
  20.     if ( (HDRunner = (StringHandle)GetResource('STR ', R_RUNNER)) == NULL) {
  21.         SysBeep(5);
  22.         ExitToShell();
  23.     }
  24.  
  25.     if (FSFCBLen > 0) {                        /* Running HFS */
  26.         myHPB.volumeParam.ioCompletion = NULL;
  27.         myHPB.volumeParam.ioVRefNum = 0;    /* default volume */
  28.         myHPB.volumeParam.ioNamePtr = NULL;
  29.         myHPB.volumeParam.ioVolIndex = 0;        /* not indexed call */
  30.         
  31.         if (PBHGetVInfo(&myHPB, FALSE) != noErr) {
  32.             SysBeep(6);
  33.             ExitToShell();
  34.         }
  35.         
  36.         /* SetVol to the blessed folder */
  37.         myWDPB.ioCompletion = NULL;
  38.         myWDPB.ioNamePtr = NULL;
  39.         myWDPB.ioVRefNum = 0;                /* default volume */
  40.         myWDPB.ioWDDirID = myHPB.volumeParam.ioVFndrInfo[1];
  41.  
  42.         if (PBHSetVol(&myWDPB, FALSE) != noErr) {
  43.             SysBeep(7);
  44.             ExitToShell();
  45.         }
  46.     }
  47.  
  48.     Launch(0, *HDRunner);
  49. }
  50.